package com.chalk.service;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.chalk.common.util.Result;
import com.chalk.model.Member;
import com.chalk.model.TicketOrder;
import com.chalk.model.TicketOrderItem;
import com.chalk.vo.TicketOrderVo;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;


/**
 * <p>
 * 服务类
 * </p>
 *
 * @author glq
 * @since 2020-12-24
 */

public interface TicketOrderService extends IService<TicketOrder> {
    /**
     * 新增
     */
    public int addTicketOrder(TicketOrder entity);

    /**
     * 修改
     */
    public int updateTicketOrder(TicketOrder entity);

    /**
     * 删除
     */
    public int deleteTicketOrder(Integer id);

    /**
     * 小程序-检查票订单金额 和 订单详情加起来的金额是否一致
     * @param total
     * @param ticketOrderItems
     * @return
     */
    public Boolean checkTicketOrderTotal(BigDecimal total, List<TicketOrderItem> ticketOrderItems);

    /**
     * 小程序-检查票是否不存在
     * @param ticketOrderItems
     * @return
     */
    public Boolean checkTicketIsNotExist(List<TicketOrderItem> ticketOrderItems);

    /**
     * 小程序-生成票订单
     * @param ticketOrderVo
     * @return
     */
    public Map<String,Object> generateTicketOrder(TicketOrderVo ticketOrderVo, Member member);

    /**
     * 小程序-检查票的库存是否充足
     * @param ticketOrderItems
     * @return
     */
    public Boolean checkTicketStock(List<TicketOrderItem> ticketOrderItems);

    /**
     * 小程序-更新票库存
     * @param ticketOrderId
     * @return
     */
    public Boolean updateTicketStock(Integer ticketOrderId);

    /**
     * 小程序-生成微信预支付订单
     * @param ticketOrderId
     * @return
     */
    public Result generateWxMiniOrder(Integer ticketOrderId,Member member);

    /**
     * 小程序-组合订单名称提交到微信
     * @param ticketOrderId
     * @return
     */
    public String composeTicketName(Integer ticketOrderId);


    /**
     * 小程序-支付成功的回调
     * @param ticketOrderId
     * @return
     */
    public Result onlinePaySuccess(Integer ticketOrderId);

    public Page<TicketOrder> getMyTicketOrdersForPage(Map<String,Object>map);
}
